package com.regan.erp.util;

import cn.hutool.core.util.ObjectUtil;
import com.jfinal.kit.Prop;
import com.jfinal.kit.PropKit;

/**
 * 公共配置信息读取
 * @author zhangby
 * @date 2017/12/4 上午11:52
 */
public class ConfigUtil {
    private static Prop dbConfig = null;
    private static Prop redisKey = null;
    private static Prop baseConfig = null;
    private static Prop emailConfig = null;

    public static Prop dbConfig() {
        return configFunction("db_config.properties",dbConfig);
    }
    public static Prop redisKey() {
        return configFunction("redis_config.properties",redisKey);
    }
    public static Prop baseConfig() {
        return configFunction("base_config.properties",baseConfig);
    }
    public static Prop emailConfig() {
        return configFunction("email.properties",emailConfig);
    }

    /**
     * 读取系统配置信息
     * @param configName
     * @return
     */
    private static Prop configFunction(String configName,Prop prop) {
        if (ObjectUtil.isNull(prop)) {
            prop = PropKit.use(configName);
        }
        return prop;
    }

}
